package avicit.bdp.dds.dao.entity;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.Id;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

@Table(name = "bdp_alert")
public class Alert extends BaseDTO {

    /**
     * primary key
     */
    @Id
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    /**
     * 标题
     */
    @Column(name = "title")
    private String title;

    /**
     * 内容
     */
    @Column(name = "content")
    private String content;

    /**
     * 告警类型
     */
    @Column(name = "process_definition_type")
    private int processDefinitionType;


    /**
     * alert_status  AlertStatus
     * 状态：0--等待执行；1--成功；2--失败
     */
    @Column(name = "status")
    private Integer alertStatus;
    /**
     * log
     */
    @Column(name = "log")
    private String log;

    /**
     * 流程定义Id
     */
    @Column(name = "process_definition_id")
    private String processDefinitionId;

    /**
     * 流程实例id
     */
    @Column(name = "process_instance_id")
    private String processInstanceId;

    /**
     * 通知的用户
     */
    @Column(name = "user_ids")
    private String userIds;




    @Transient
    private Map<String, Object> info = new HashMap<>();

    public Alert() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getAlertStatus() {
        return alertStatus;
    }

    public void setAlertStatus(Integer alertStatus) {
        this.alertStatus = alertStatus;
    }

    public String getLog() {
        return log;
    }

    public void setLog(String log) {
        this.log = log;
    }

   
    public Map<String, Object> getInfo() {
        return info;
    }

    public void setInfo(Map<String, Object> info) {
        this.info = info;
    }
    
    

    public int getProcessDefinitionType() {
		return processDefinitionType;
	}

	public void setProcessDefinitionType(int processDefinitionType) {
		this.processDefinitionType = processDefinitionType;
	}

	public String getProcessDefinitionId() {
		return processDefinitionId;
	}

	public void setProcessDefinitionId(String processDefinitionId) {
		this.processDefinitionId = processDefinitionId;
	}

	public String getProcessInstanceId() {
		return processInstanceId;
	}

	public void setProcessInstanceId(String processInstanceId) {
		this.processInstanceId = processInstanceId;
	}

	public String getUserIds() {
		return userIds;
	}

	public void setUserIds(String userIds) {
		this.userIds = userIds;
	}

	@Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Alert alert = (Alert) o;

        if (!id.equals(alert.id)) {
            return false;
        }
     
        if (!title.equals(alert.title)) {
            return false;
        }
    
        if (!content.equals(alert.content)) {
            return false;
        }
     
        if (alertStatus != alert.alertStatus) {
            return false;
        }
        if (!log.equals(alert.log)) {
            return false;
        }
      
        if (!creationDate.equals(alert.creationDate)) {
            return false;
        }
        return lastUpdateDate.equals(alert.lastUpdateDate) && info.equals(alert.info);

    }

    @Override
    public int hashCode() {
        return Objects.hash(id, title, content, processDefinitionType, alertStatus,log,
                processDefinitionId, processInstanceId, userIds,info);
    }

    @Override
    public String toString() {
        return "Alert{" +
                "id='" + id + '\'' +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", processDefinitionType=" + processDefinitionType +
                ", alertStatus=" + alertStatus +
                ", log='" + log + '\'' +
                ", processDefinitionId='" + processDefinitionId + '\'' +
                ", processInstanceId='" + processInstanceId + '\'' +
                ", userIds='" + userIds + '\'' +
                ", info=" + info +
                '}';
    }
}
